package com.yd.controller.yd;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Properties;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


public class YD_Sys {
	//通过管理員token查询
	public static JSONObject getshidByToken(String token) throws MalformedURLException, IOException{
		
		String urlruls=getUrlValue("urlruls.token")+token;
		Document doc = Jsoup.parse(new URL(urlruls).openStream(), "UTF-8", urlruls);
		String str=doc.select("body").text().trim();
		JSONObject jso=JSON.parseObject(str);
		return jso;
	}
	
	
	
	public static String getUrlValue(String urlName) {
        String url = null;
        Properties prop = new Properties();
        try {
            ClassLoader classLoader = YD_Sys.class.getClassLoader();// 读取属性文件xxxxx.properties
            InputStream in = classLoader.getResourceAsStream("url_sys.properties");
            prop.load(in); /// 加载属性列表
            Iterator<String> it = prop.stringPropertyNames().iterator();
            while (it.hasNext()) {
                if (it.next().equals(urlName)) {
                    url = prop.getProperty(urlName);
                }
            }
            in.close();
        } catch (Exception e) {
            
        }
        return url;
    }
	
	
	public static void main(String[] args) {
		System.out.println(getUrlValue("urlruls.token"));
		
	}
	
//	public static void main(String[] args) throws MalformedURLException, IOException {
//		
//		/*
//		JSONObject yd_users_token=YD_Users.getUsersByToken(token);
//		if(yd_users_token.getString("error").equals("1")){
//			System.out.println(yd_users_token.getString("msg"));
//		}
//		JSONObject users_token=JSONObject.parseObject(yd_users_token.getString("data"));
//		*/
//		
//		/*
//		JSONObject yd_users_uid=YD_Users.getUsersByUid(uid);
//		if(yd_users_uid.getString("error").equals("1")){
//			System.out.println(yd_users_uid.getString("msg"));
//		}
//		JSONObject users_uid=JSONObject.parseObject(yd_users_uid.getString("data"));
//		*/
//		
//
//		JSONObject yd_users_uid=YD_Users.getUsersByUid("20");
//		if(yd_users_uid.getString("error").equals("1")){
//			System.out.println(yd_users_uid.getString("msg"));
//		}
//		JSONObject users_uid=JSONObject.parseObject(yd_users_uid.getString("data"));
//		
//		System.out.println(users_uid.getString("phone"));
//	}
	
	
	
	
}

















